package cn.study.luckyinfrastructure.convertor;

import cn.study.luckydomain.prize.Inventory;
import cn.study.luckydomain.prize.PrizeEntity;
import cn.study.luckyinfrastructure.gateway.iml.dataObject.PrizeDB;

import java.time.LocalDateTime;

public class PrizeConvertor {
    public static PrizeDB toPrizeDB(PrizeEntity prizeEntity){
        PrizeDB prizeDB = new PrizeDB();
        prizeDB.setId(prizeEntity.getId());
        prizeDB.setPrizeName(prizeEntity.getPrizeName());
        prizeDB.setInventory(prizeEntity.getInventory().getInventory());
        prizeDB.setMoney(prizeEntity.getMoney());
        prizeDB.setType(prizeEntity.getType());
        prizeDB.setCreateTime(prizeEntity.getCreateTime());
        prizeDB.setCretor(prizeEntity.getCretor());
        prizeDB.setUpdateTime(prizeEntity.getUpdateTime());
        prizeDB.setUpdater(prizeDB.getUpdater());
        return prizeDB;
    }
    public static PrizeEntity toEntity(PrizeDB prizeDB){
        PrizeEntity prizeEntity = new PrizeEntity();
        prizeEntity.setId(prizeDB.getId());
        prizeEntity.setPrizeName(prizeDB.getPrizeName());
        prizeEntity.setInventory(new Inventory(prizeDB.getInventory()));
        prizeEntity.setMoney(prizeDB.getMoney());
        prizeEntity.setType(prizeDB.getType());
        prizeEntity.setCreateTime(prizeDB.getCreateTime());
        prizeEntity.setCretor(prizeDB.getCretor());
        prizeEntity.setUpdateTime(prizeDB.getUpdateTime());
        prizeEntity.setUpdater(prizeDB.getUpdater());
        return prizeEntity;
    }
}
